#规约（枚举类）
class Target:
    ACCEPT = 0
    REJECT = 1


#协议
class Protocol:
    ICMP_V4  = 1
    TCP      = 6
    UDP      = 17
    ICMP_V6  = 58


#入/出方向
class Direction:
    INPUT  = 0
    OUTPUT = 1



#前端发送过来的规则的格式
class Rule:
    direction :Direction           #入/出方向
    target    :Target              #允许/禁止
    num       :int                 #优先级 - 规则的num，也就是下标
    protocol  :Protocol            #协议
    src       :str                 #源地址
    sport     :int                 #源端口
    dst       :str                 #目的地址
    dport     :int                 #目的端口

    #从用户数据创建
    def __init__(self,rule):
        self.direction = rule['direction']
        self.target = rule['target']
        self.num = rule['num']
        self.protocol = rule['protocol']
        self.src = rule['src']
        self.sport = rule['sport']
        self.dst = rule['dst']
        self.dport = rule['dport']
    







